
import './assets/main.css'
import 'animate.css';
import 'hover.css';
import router from './router'
import { cfg } from './cfg/cfg.js'
import VueDOMPurifyHTML from 'vue-dompurify-html';   //反xss
import { darkTheme } from "naive-ui"; // 100kb
import App from './App.vue' //140kb
import { theme_css as def_css } from "./assets/layui/def/css.js"; //LAYUI 默认JS主题 //1kb
import { theme_css as dark_css } from "./assets/layui/dark/css.js"; //LAYUI 黑色JS主题 //1kb
import { theme_css as white_css } from "./assets/layui/white/css.js"; //LAYUI 白色JS主题 //1kb
import new_model from "@/comp/new_modal.vue";
import auto_page from "@/comp/auto_page.vue";
import auto_tabs from "@/comp/auto_tabs.vue";
import auto_role from "@/comp/auto_role.vue";
import auto_menu from "@/comp/auto_menu.vue";
import loginbox from "@/comp/loginbox.vue";
import { merge } from 'lodash-es';
import { funs } from './cfg/function.js'
import { Dialog,Lazyload } from 'vant';
import 'vant/lib/index.css';

import FastClick from 'fastclick';
const fastclick = new FastClick(document.body);  // 实例化
let app;

if (app == null) {
    //手机识别
    const userAgent = navigator.userAgent || navigator.vendor || window.opera;
    const mobileRegex = /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i;
    cfg.mobile = mobileRegex.test(userAgent);
    //APP识别 删除不需要
    cfg.apprun = false;
    if (cfg.apprun == true || cfg.mobile == true) {
        cfg.mbcard = `padding: 0.5rem;`;
        cfg.apph = `0`;
    }
    let diycssv2 = {};
    let diycssbase = {};
    diycssv2['darkTheme'] = merge({}, def_css, dark_css);
    diycssbase['darkTheme'] = darkTheme;
   diycssv2['lightTheme'] = merge({}, def_css, white_css);
    diycssbase['lightTheme'] = {};
    cfg.apph = `55`;
    cfg.function = { ...funs, ...cfg.function }
    const diycss = {};
    app = createApp(App)
    app.use(router)
    app.use(VueDOMPurifyHTML);
    app.use(Lazyload);
    app.use(Lazyload, {
        lazyComponent: true,
      });
    window.router = router;
    app.config.globalProperties.$set = {
        mb : mobileRegex.test(userAgent),
    };
    app.config.globalProperties.$diycss = diycss;
    app.config.globalProperties.$cfg = cfg;
    app.config.globalProperties.$diycssv2 = diycssv2;
    app.config.globalProperties.$diycssbase = diycssbase;
    
    app.component('m-win', new_model);
    app.component('m-page', auto_page);
    app.component('m-tabs', auto_tabs);
    app.component('m-login-box', loginbox);
    app.component('m-role', auto_role);
    app.component('m-menu', auto_menu);
    app.component(Dialog.name,Dialog);
    app.mount('#app')

    

}

